package weixin;

public class WechatParam {
	private volatile static String appId;
	private volatile static String appsecret;
	private volatile static String account;
	private volatile static String token;
	private volatile static String access_token;//微信基本都要用它
	private volatile static long access_token_time;//调用时间
	private volatile static String api_ticket;//调用jsAPI要用他
	private volatile static long api_ticket_time;//调用时间
	public final static long access_token_baseTime=1800;//过期时间
	public final static long api_ticket_baseTime=1830;//过期时间
	public static String getAppId() {
		return appId;
	}
	public static void setAppId(String appId) {
		WechatParam.appId = appId;
	}
	public static String getAppsecret() {
		return appsecret;
	}
	public static void setAppsecret(String appsecret) {
		WechatParam.appsecret = appsecret;
	}

	public static String getAccount() {
		return account;
	}
	
	public static void setAccount(String account) {
		WechatParam.account = account;
	}
	public static String getToken() {
		return token;
	}
	public static void setToken(String token) {
		WechatParam.token = token;
	}
	public static String getAccess_token() {
		return access_token;
	}
	public static void setAccess_token(String access_token) {
		WechatParam.access_token = access_token;
	}
	public static long getAccess_token_time() {
		return access_token_time;
	}
	public static void setAccess_token_time(long access_token_time) {
		WechatParam.access_token_time = access_token_time;
	}
	public static String getApi_ticket() {
		return api_ticket;
	}
	public static void setApi_ticket(String api_ticket) {
		WechatParam.api_ticket = api_ticket;
	}
	public static long getApi_ticket_time() {
		return api_ticket_time;
	}
	public static void setApi_ticket_time(long api_ticket_time) {
		WechatParam.api_ticket_time = api_ticket_time;
	}
	 /**
	 *@note: 检查AccessToken，true为通过，false为不通过	
	 *@date: 2017年4月22日 下午2:05:39
	 *@param time
	 *@return
	 */
	public static boolean checkTimeAccessToken(long time) {
		if(time==0){//initWechatParam 初始化的时候，如果没有获取过access_token 和jsapi_ticket ，则时间会为0
			return false;
		}
		long sysTime = System.currentTimeMillis();
		long wxbaseNum = (7200 - access_token_baseTime) * 1000;// 超时时间
		if (sysTime >= time && (sysTime < time + wxbaseNum)) { // 获取时间-----------当前时间--------------结束时间
			return true;
		} else {
			return false;
		}

	}
	/**
	 *@note: 校验	ApiTicket  true为通过，false为不通过	
	 *@date: 2017年7月9日 下午3:25:48
	 *@param time
	 *@return
	 */
	public static boolean checkTimeApiTicket(long time) {
		if(time==0){//initWechatParam 初始化的时候，如果没有获取过access_token 和jsapi_ticket ，则时间会为0
			return false;
		}
		long sysTime = System.currentTimeMillis();
		long wxbaseNum = (7200 - api_ticket_baseTime) * 1000;// 超时时间
		if (sysTime >= time && (sysTime < time + wxbaseNum)) { // 获取时间-----------当前时间--------------结束时间
			return true;
		} else {
			return false;
		}

	}
}
